package controllers;

import connectivity.Dbmanager;
import connectivity.QueryManager;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class DeleteModuleController extends HttpServlet {

    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {


        Dbmanager dbManager = new Dbmanager();
        dbManager.openConnection();
        QueryManager queryManager = new QueryManager(dbManager);
        String address;

        if (request.getParameter("moduledelete") != null) {
            queryManager.deletemodulebyid(Integer.parseInt(request.getParameter("moduledelete")));

            address = "subscribe_to_course";

            dbManager.closeConnection();
            RequestDispatcher dispatcher = request.getRequestDispatcher(address);

            dispatcher.forward(request, response);

        }
        
        dbManager.closeConnection();
    }
}
